from selenium.webdriver.common.by import By
from homework.web.config.base_data import url
from homework.web.page.base_page import BasePage
from homework.web.page.search_page import SearchPage

class CeshirenPage(BasePage):
    def __init__(self):
        # 访问ceshiren网站
        super().__init__()
        self.driver.get(url)
        # 隐式等待5s
        self.driver.implicitly_wait(5)

    def open_search(self):
        # 点击搜索图标
        self.click(By.CSS_SELECTOR, '#search-button')
        # 点击搜索输入框的按钮打开高级搜索
        self.click(By.CSS_SELECTOR, '[title="打开高级搜索"]')
        # 返回搜索页面
        return SearchPage(self.driver)

    def close(self):
        # 关闭浏览器
        self.driver.close()
